﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Acoris.Rendering
{
    /// <summary>
    /// 表示一个字形
    /// </summary>
    public abstract class Glyph:TextElement
    {        

        /// <summary>
        /// 
        /// </summary>
        public struct GlyphBrush
        {
            public int index;
            public int count;
            public object data;
        }

        /// <summary>
        /// 
        /// </summary>
        public enum ScriptType
        {
            SubScript,
            SuperScript
        }

        protected IList<GlyphBrush> GlyphBrushList;

        public Glyph()
        {
            GlyphBrushList = new List<GlyphBrush>();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <param name="count"></param>
        public void SetSuperScript(int index, int count)
        {

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <param name="count"></param>
        public void SetSubScript(int index, int count)
        {

        }

        internal override void CreateResources(IDrawingContext drawingContext)
        {
            var factory = drawingContext.Factory;
            if (!CacheResult)
            {
#if WIN2D
                TextFormat = Cache(factory.GetTextFormat(Format));
                ForegroundBrush = Cache(factory.GetBrush(Format.Foreground));
                TextLayout = Cache(factory.CreateTextLayout(this.Text, TextFormat));
                TextLayout.SetCustomBrush(0, 1, GlyphBrushList);
#endif
            }
        }
    }
}
